<?php

$img = glob('public/upload/paginasite/'.$this->paginasite['PGS_ID'].'.*');
@$img = $img[0];

?>
<div id="bnn_pag" style="background-image: url('<?php echo $this->urlbase.'/'.$img; ?>'); ?>"></div>

<div id="ctn_revenda">
    
    <div class="c_r_spc">
        <form id="form" method="post">
            Localização: 
            <select id="estado" name="estado" class="estado">
                <option value="">Estados</option>
            <?php foreach($this->estados as $row){
                $selected = $row['EST_ID'] == $this->uf ? 'selected=""':'';
            ?>
                <option <?php echo $selected; ?> value="<?php echo $row['EST_ID']; ?>"><?php echo $row['EST_UF']; ?></option>
            <?php } ?>
            </select>
            
            <select id="cidade" name="cidade" class="cidade">
                <option value="">Cidades</option>
                <?php foreach($this->cidades as $row){
                    $selected = $row['CID_ID'] == $this->cidade ? 'selected=""':'';
                ?>
                 <option <?php echo $selected; ?> value="<?php echo $row['CID_ID']; ?>"><?php echo $row['CID_NOM']; ?></option>
                <?php } ?>
            </select>
        </form>   
        
        <ul>
        <?php
        foreach($this->result as $row){
            $imgs = glob('public/upload/revenda/'.$row['REV_ID'].'.*');
            $img = '';
            if($imgs[0]) $img = '<img src="'.$this->urlbase.'/'.$imgs[0].'" />';
            
            $query = 'SELECT SQL_CACHE EST_UF FROM ESTADOS WHERE EST_ID = '.$row['EST_ID'];
            $res= $this->db->fetchRow($query);
            $uf = $res['EST_UF'];
            
            $query = 'SELECT SQL_CACHE CID_NOM FROM CIDADES WHERE CID_ID = '.$row['CID_ID'];
            $res= $this->db->fetchRow($query);
            $cid = $res['CID_NOM'];
            
            $end = $row['REV_END'].', '.$row['REV_BAI'].', '.$cid.' - '.$uf;
            
        ?>
            <li>
                <div class="c_r_fot"><img src="<?php echo $this->urlbase.'/'.$imgs[0]; ?>" /></div>
                <div class="c_r_end">
                    <ul>
                        <?php if(strlen($row['REV_NOM']) > 0){ ?><li class="c_r_til"><?php echo $row['REV_NOM']; ?></li><?php } ?>
                        <?php if(strlen($end) > 0){ ?><li>End.: <?php echo $end; ?></li><?php } ?>
                        <?php if(strlen($row['REV_TEL']) > 0){ ?><li>Tel.: <?php echo $row['REV_TEL']; ?></li><?php } ?>
                        <?php if(strlen($row['REV_EML']) > 0){ ?><li>E-mail: <?php echo $row['REV_EML']; ?></li><?php } ?>
                        <?php if(strlen($row['REV_SIT']) > 0){ ?>
                            <li>Site: 
                                <a href="<?php echo 'http://'.str_replace('http://', '', $row['REV_SIT']); ?>" target="_balck">
                                    <?php echo $row['REV_SIT']; ?>
                                </a>
                            </li>
                        <?php } ?>
                        <?php if(strlen($row['REV_MAP']) > 0){ ?><li>
                                <a href="<?php echo $row['REV_MAP']; ?>" target="_balck">
                                    Veja nossa localização no mapa
                                </a>
                            </li>
                        <?php } ?>
                    </ul>
                </div>
            </li>
        <?php } ?>
        </ul>    
        
    </div>
</div>


<div class="rodape-home">
    <div class="r_h_cnt">
        <ul class="l-menu">
        <?php foreach($this->sessao_paginasite as $pag) { ?>
            <li><a href="<?php echo $this->urlbase.'/'.$pag['PGS_LNK']; ?>"><?php echo $pag['PGS_NOM']; ?></a></li>
        <?php } ?>
        </ul>

        <ul class="l-menu">
        <?php foreach($this->sessao_ambientes as $amb) { ?>
            <li><a href="<?php echo $this->urlbase.'/ambientes/detalhe/id/'.$amb['AMB_ID']; ?>"><?php echo $amb['AMB_NOM']; ?></a></li>
        <?php } ?>
        </ul>

        <div class="cnt_logo_end">
            <a class="c_l_e_logo" href="<?php echo $this->urlbase.'/'; ?>"><img src="<?php echo $this->urlbase.'/public/media/images/logo_rp.png'; ?>"></a>
            <?php
                $pref = '54';
                $telefone = $this->parametros['PAR_TEL'];
                if(strlen($telefone) > 5){
                    $telefone = $this->parametros['PAR_TEL'];
                    $temp = explode(' ',$telefone);
                    $pref = $temp[0];
                    $telefone = $temp[1];
                    if(isset($temp[2]) && strlen($temp[2]) > 2) $telefone .= '.'.$temp[2];
                }
            ?>
            <div class="telefone"><span><?php echo $pref; ?></span> <?php echo $telefone; ?></div>
            <?php if(strlen($this->parametros['PAR_FAC']) > 5) {?>
            <a href="<?php echo $this->parametros['PAR_FAC']; ?>" target="_blank"><img src="<?php echo $this->urlbase.'/public/media/images/facebook.png'; ?>" alt="facebook"></a>
            <?php } ?>
        </div>
    </div>
</div>
<div class="bar-bottom"></div>